package com.lby.graduation.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*cors跨域资源共享
* 全局配置
* */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")//表示接受任意域名的请求
                .allowedMethods("POST", "HEAD", "GET", "PUT", "OPTIONS", "DELETE")
                .allowCredentials(false)
                .maxAge(3600)
                .allowedHeaders("*");
    }

}